home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / graphic / fgdemo10.zip / DISPLAY.C < prev    next >
Text File  |  1991-10-02  |  9KB  |  334 lines

  1. /**********************************************************************\
  2. *                                                                      *
  3. *  display.c -- graphics display functions, bitmaps, scrolling, etc.   *
  4. *                                                                      *
  5. \**********************************************************************/
  6.  
  7. #include "defs.h"
  8. #include "bitmaps.h"
  9.  
  10. /**********************************************************************\
  11. *                                                                      *
  12. *  do_bitmaps -- display some bitmaps on the screen                    *
  13. *                                                                      *
  14. \**********************************************************************/
  15.  
  16. do_bitmaps()
  17. {
  18.  
  19.    /* width, height, position and colors of TNT plunger bitmap */
  20.  
  21.    static int tnt_width[]   = { 6,  3,  4,  4};
  22.    static int tnt_height[]  = {28, 25, 27, 17};
  23.    static int tnt_color[]   = { 0,  7,  8, 15};
  24.    static int tnt_xoffset[] = { 0, 24, 16, 16};
  25.    static int tnt_yoffset[] = { 0, -2, -1, -2};
  26.    static char *tnt_bitmap[4] = {tnt0,tnt7,tnt8,tnt15};
  27.  
  28.    /* width, height, position and colors of "kablooy" explosion */
  29.  
  30.    static int kablooy_width[]   = {13,  6};
  31.    static int kablooy_height[]  = {53,  8};
  32.    static int kablooy_color[]   = { 4, 15};
  33.    static int kablooy_xoffset[] = { 0, 29};
  34.    static int kablooy_yoffset[] = { 0,-24};
  35.    static char *kablooy_bitmap[2] = {kablooy4,kablooy15};
  36.  
  37.    /* strings for info window */
  38.  
  39.    static char *string[] = {
  40.    "Bitmaps",
  41.    "Bitmaps can be clipped, flipped, mode-independent",
  42.    "and mode-specific.",
  43.    };
  44.  
  45.    register int i;
  46.    int x,y;
  47.    int ymin,ymax;
  48.  
  49.    /* clear lower part of screen */
  50.  
  51.    fg_mousevis(OFF);
  52.    fg_restore(0,xlimit,menu_bottom,ylimit);
  53.  
  54.    /* display the info window */
  55.  
  56.    info_window(120,520,60,string,3);
  57.  
  58.    /* calculate where the TNT bitmap is going to go */
  59.  
  60.    ymin = scale(60);
  61.    ymax = ymin + 4 * (ptsize+1);
  62.  
  63.    x = 520;
  64.    y = ymax;
  65.  
  66.    /* put the TNT bitmap next to the info window */
  67.  
  68.    fg_mousevis(OFF);
  69.    for (i = 0; i < 4; i++)
  70.    {
  71.       fg_move(x+tnt_xoffset[i],y+tnt_yoffset[i]);
  72.       fg_setcolor(tnt_color[i]);
  73.       fg_drawmap(tnt_bitmap[i],tnt_width[i],tnt_height[i]);
  74.    }
  75.  
  76.    /* save info window to hidden page, to be replaced after the explosion */
  77.  
  78.    x = 440;
  79.    y = ymax + 20;
  80.    fg_save(400,520,ymin,y);
  81.  
  82.    /* take a rectangular bite out of the info window on the hidden page */
  83.  
  84.    fg_transfer(464,568,144,180,464,y-10,hidden,hidden);
  85.  
  86.    /* pause 1 second */
  87.  
  88.    fg_mousevis(ON);
  89.    fg_waitfor(18);
  90.  
  91.    /* move the plunger down */
  92.  
  93.    fg_mousevis(OFF);
  94.    fg_transfer(544,567,ymax-30,ymax-25,544,ymax-23,visual,visual);
  95.    fg_mousevis(ON);
  96.    fg_waitfor(6);
  97.  
  98.    fg_mousevis(OFF);
  99.    fg_transfer(544,567,ymax-28,ymax-23,544,ymax-21,visual,visual);
  100.    fg_mousevis(ON);
  101.    fg_waitfor(6);
  102.    fg_mousevis(OFF);
  103.  
  104.    /* display the explosion */
  105.  
  106.    for (i = 0; i < 2; i++)
  107.    {
  108.       fg_move(x+kablooy_xoffset[i],y+kablooy_yoffset[i]);
  109.       fg_setcolor(kablooy_color[i]);
  110.       fg_drawmap(kablooy_bitmap[i],kablooy_width[i],kablooy_height[i]);
  111.    }
  112.  
  113.    /* blink the "kablooy" text 4 times */
  114.  
  115.    for (i = 0; i < 4; i++)
  116.    {
  117.       fg_waitfor(3);
  118.       fg_move(x+kablooy_xoffset[1],y+kablooy_yoffset[1]);
  119.       fg_setcolor(4);
  120.       fg_drawmap(kablooy_bitmap[1],kablooy_width[1],kablooy_height[1]);
  121.       fg_waitfor(3);
  122.       fg_move(x+kablooy_xoffset[1],y+kablooy_yoffset[1]);
  123.       fg_setcolor(15);
  124.       fg_drawmap(kablooy_bitmap[1],kablooy_width[1],kablooy_height[1]);
  125.    }
  126.  
  127.    /* wait a bit, then restore the info window with the corner missing */
  128.  
  129.    fg_waitfor(3);
  130.    fg_restore(440,568,y-68,y);
  131.  
  132.    /* draw the torn edges of the info window using the tear bitmap */
  133.  
  134.    fg_setcolor(0);
  135.    fg_move(461,ymax);
  136.    fg_drawmap(tear,8,29);
  137.  
  138.    /* restore all the stuff on the hidden page */
  139.  
  140.    draw_screen();
  141.  
  142.    /* wait for a keystroke, restore the visual page, and return */
  143.  
  144.    fg_mousevis(ON);
  145.    wait_for_keystroke();
  146.  
  147.    fg_mousevis(OFF);
  148.    fg_restore(0,xlimit,menu_bottom,ylimit);
  149.  
  150.    fg_mousevis(ON);
  151.    redraw = TRUE;
  152.  
  153.    return(OK);
  154. }
  155.  
  156. /**********************************************************************\
  157. *                                                                      *
  158. *  do_scroll -- do a circular scroll of part of the screen             *
  159. *                                                                      *
  160. \**********************************************************************/
  161.  
  162. do_scroll()
  163. {
  164.    register int i;
  165.    int y1,y2;
  166.  
  167.    y1 = scale(4);
  168.    y2 = ylimit - y1;
  169.  
  170.    fg_mousevis(OFF);
  171.  
  172.    /* save the area under the scroll */
  173.  
  174.    fg_transfer(280,439,y1,y2,0,y2,hidden,hidden);
  175.  
  176.    /* do a nice circular scroll */
  177.  
  178.    for (i = y1; i <= y2; i+=2)
  179.       fg_scroll(280,439,y1,y2,-2,0);
  180.  
  181.    /* fix the area under the scroll */
  182.  
  183.    fg_transfer(0,159,y1,y2,280,y2,hidden,hidden);
  184.    fg_save(0,159,y1,y2);
  185.  
  186.    fg_mousevis(ON);
  187.    return(OK);
  188. }
  189.  
  190. /**********************************************************************\
  191. *                                                                      *
  192. * do_transfer -- demo the transfer function                            *
  193. *                                                                      *
  194. \**********************************************************************/
  195.  
  196. do_transfer()
  197. {
  198.    register int i;
  199.    int x,y;
  200.    int ymin,ymax;
  201.  
  202.    static char *string[] = {
  203.    "Transfer",
  204.    "Use Fastgraph's image transfer routines",
  205.    "to copy rectangular areas, either on the",
  206.    "same video page or different video pages."
  207.     };
  208.  
  209.    /* clear work area of visual page and display the info window */
  210.  
  211.    fg_mousevis(OFF);
  212.    fg_restore(0,xlimit,menu_bottom,ylimit);
  213.    info_window(24,419,60,string,4);
  214.  
  215.    /* save the info window to the hidden page */
  216.  
  217.    ymin = scale(60);
  218.    ymax = ymin + 5 * (ptsize+1) + 2;
  219.    fg_save(24,419,ymin,ymax);
  220.  
  221.    /* transfer a 6 copies of the info window from hidden page to visual */
  222.  
  223.    x = 56;
  224.    y = ymax+ptsize+1;
  225.    for (i = 0; i < 6; i++)
  226.    {
  227.       fg_transfer(24,419,ymin,ymax,x,y,hidden,visual);
  228.       x += 32;
  229.       y += ptsize;
  230.       fg_waitfor(2);
  231.    }
  232.  
  233.    /* wait for a keystroke */
  234.  
  235.    fg_mousevis(ON);
  236.    wait_for_keystroke();
  237.  
  238.    fg_mousevis(OFF);
  239.  
  240.    /* clear the area where the info window was on the hidden page */
  241.  
  242.    y = 5 * (ptsize+1) + 2;
  243.  
  244.    fg_transfer(24,419,ymax+1,ymax+y+1,24,ymax,hidden,hidden);
  245.  
  246.    /* restore the screen and return */
  247.  
  248.    fg_restore(0,xlimit,menu_bottom,ylimit);
  249.    redraw = TRUE;
  250.  
  251.    fg_mousevis(ON);
  252.    return(OK);
  253. }
  254.  
  255. /**********************************************************************\
  256. *                                                                      *
  257. *  view_graphic -- display a graphic image for the selected product    *
  258. *                                                                      *
  259. \**********************************************************************/
  260.  
  261. view_graphic()
  262. {
  263.    int xmin, xmax, ymin, ymax;
  264.  
  265.    static int defaults[] = {0,1,2,3,4,5,20, 7,56,57,58,59,60,61,62,63};
  266.  
  267.    fg_mousevis(OFF);
  268.    fg_restore(0,xlimit,menu_bottom,ylimit);
  269.  
  270.    /* define the window extremes */
  271.  
  272.    xmin = 210;
  273.    xmax = 430;
  274.    ymin = scale(145);
  275.    ymax = scale(205);
  276.  
  277.    /* display the status window */
  278.  
  279.    draw_window(xmin,xmax,ymin,ymax,"View Graphic");
  280.    fg_setcolor(0);
  281.  
  282.    /* if using the proper video mode, display the image */
  283.  
  284.    if (mode == 16)
  285.    {
  286.       center_pstring("Loading image...",xmin,xmax,ymin+row_offset(3));
  287.  
  288.       /* display the graphic on the hidden page */
  289.  
  290.       fg_setpage(hidden);
  291.       fg_move(0,ylimit);
  292.       fg_dispfile("casino.ppr",xlimit+1,1);
  293.       fg_setpage(visual);
  294.  
  295.       /* need to adjust the palettes for this graphic */
  296.  
  297.       fg_palette(7,38);
  298.       fg_palette(13,39);
  299.       fg_fadein(0);
  300.  
  301.       /* restore the hidden page */
  302.  
  303.       draw_screen();
  304.  
  305.       /* wait for a